package com.oohoo.spacestationspringbootstarter.dto.query;

import com.oohoo.spacestationspringbootstarter.dto.query.annotation.From;
import com.oohoo.spacestationspringbootstarter.dto.query.exception.DtoQueryException;

import java.io.Serializable;

/**
 * @author Lei Li. leeoohoo@gmail.com
 * @Description
 * @since 14 November 2022
 */
public interface DTO extends Serializable {



    default Class<?> currentTable() {
        Class<? extends DTO> aClass = this.getClass();
        From annotation = aClass.getAnnotation(From.class);
        if(null == annotation) {
            throw new DtoQueryException("DTO 缺少@From注解");
        }
        return annotation.value();
    }
}
